package com.neuedu.projos;

import java.util.List;

public class ProductPage<T> {

	public ProductPage(Integer pageNum, Integer pageSize, Integer allRecords) {
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.allRecords = allRecords;
		if(allRecords%pageSize==0) {
			allPages = allRecords/pageSize;
		}
		else {
			allPages = allRecords/pageSize + 1;
		}
		this.startIndex=(this.pageNum-1)*this.pageSize;
		this.startPage = 1;
		this.endPage = 5;
		if(endPage<=5)
		{
			this.startPage = 1;
			this.endPage = this.allPages;
		}
		else{
			this.startPage = this.pageNum -2;
			this.endPage = this.pageNum +2;	
		}
		if(this.startPage<=0)
		{
			this.startPage = 1;
			this.endPage = 5;
		}
		if(this.endPage > this.allPages)
		{
			this.endPage = this.allPages;
			this.startPage = this.endPage -4;
		}
	}
	public Integer getPageNum() {
		return pageNum;
	}
	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getAllPages() {
		return allPages;
	}
	public void setAllPages(Integer allPages) {
		this.allPages = allPages;
	}
	public Integer getAllRecords() {
		return allRecords;
	}
	public void setAllRecords(Integer allRecords) {
		this.allRecords = allRecords;
	}
	public Integer getStartIndex() {
		return startIndex;
	}
	public void setStartIndex(Integer startIndex) {
		this.startIndex = startIndex;
	}
	public Integer getStartPage() {
		return startPage;
	}
	public void setStartPage(Integer startPage) {
		this.startPage = startPage;
	}
	public Integer getEndPage() {
		return endPage;
	}
	public void setEndPage(Integer endPage) {
		this.endPage = endPage;
	}
	public List<T> getPros() {
		return pros;
	}
	public void setPros(List<T> pros) {
		this.pros = pros;
	}
	private Integer pageNum;
	private Integer pageSize;
	private Integer allPages;
	private Integer allRecords;
	private Integer startIndex;
	private Integer startPage;
	private Integer endPage;
	private List<T> pros;
}
